package cn.itrigger.dynamic.sql.condition;

import java.util.Objects;
import java.util.function.Supplier;

/**
 * @author admin
 * @date 2018/9/25
 **/
public abstract class AbstractTwoValueCondition<T> implements VisitableCondition<T> {

    private Supplier<T> valueSupplier1;
    private Supplier<T> valueSupplier2;

    protected AbstractTwoValueCondition(Supplier<T> valueSupplier1, Supplier<T> valueSupplier2) {
        this.valueSupplier1 = Objects.requireNonNull(valueSupplier1);
        this.valueSupplier2 = Objects.requireNonNull(valueSupplier2);
    }

    public T value1() {
        return valueSupplier1.get();
    }

    public T value2() {
        return valueSupplier2.get();
    }

    @Override
    public <R> R accept(ConditionVisitor<T, R> visitor) {
        return visitor.visit(this);
    }

    public abstract String renderCondition(String columnName, String placeholder1, String placeholder2);
}
